<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<script type="text/javascript" language="JavaScript">

function CloseMySelf(sender) {
	var radios = document.getElementsByName("radioselect");
    var formValid = false;
    var i = 0;
    while (!formValid && i < radios.length) {
        if (radios[i].checked) formValid = true;
        i++;        
    }
    if (!formValid){ alert("Must check some option!");
    return formValid;}
    else
	var x;
	var y;
    try {
    	var radios = document.getElementsByName("radioselect");
    	var i = 0;
        while (i < radios.length) {
            if (radios[i].checked){
            	x=radios[i].value;
            	y=document.getElementById(x).value;
            }
            i++;        
        }
    }
    catch (err) {}
    window.opener.document.getElementById("leadcontact").value=y;
    window.opener.document.getElementById("leadcontactid").value=x;
    window.open('','_self',''); 
    window.close(); 
    return true;
}
function closeWindow(){ 
    window.open('','_self',''); 
    window.close(); 
} 
</script>
<body>
<style>
.cot0,.cot1,.cot2,.cot3,.cot4,.cot5 {
	width: 140px;
	float: left;
	vertical-align: middle;
	display: inline-block;
	display: table-cell;
}

.cot0 {
	width: 30px;
}

.cot1 {
	width: 190px;
}
.cot3 {
	width: 150px;
}
</style>
<h1>Search Contact</h1>
<form action="searchContact" method="post">
	<div style="clear: both; padding-top: 20px; float: left; cleat: both">
		First Name: <input type="text" name="firstname"
			style="margin-right: 30px"> Surname: <input type="text"
			name="surname">
	</div>
	<div style="float: left; width: 100%; clear: both; margin: 20px 0px">
		<input class="button_css" type="submit" value="Search Contact"> <input
			type="submit" id="btNone" value="None"  class="button_css" > <input type="reset"
			id="btClear" value="Clear"  class="button_css" > <input type="submit"
			id="btCreate" value="Create"  class="button_css">
		<div style="float: right">
			<form>
				<input type="checkbox"
					onclick="window.location='?check=1'; return true;"> Include
				In-Active
			</form>
		</div>
	</div>
</form>
<div style="display: block; float: left; clear: both">
	<ul>
		<li class="li_title">
			<div class="cot0">-</div>
			<div class="cot1">Contact Name</div>
			<div class="cot2">Mobile Phone</div>
			<div class="cot3">Email</div>
			<div class="cot4">Contact Type</div>
			<div class="cot5">Is Active?</div>
		</li>
		<form action="select.html" method="post" id="page" name="page" onsubmit="checkRadio()">
		<c:forEach items="${contactList}" var="contact">
			<li>
				<div class="cot0" style="padding: 5px 2px">
				<input type="hidden" id="${contact.idcontact}" name="${contact.idcontact}" value="${contact.surname} ${contact.firstname}" />
				<input type="radio" name="radioselect" value="${contact.idcontact}" />
				</div>
				<div class="cot1">${contact.surname} ${contact.firstname}</div>
				<div class="cot2">${contact.mobile}</div>
				<div class="cot3">${contact.email}</div>
				<div class="cot4">${contact.contacttype}</div>
				<div class="cot5">${contact.active}</div>
			</li>
		</c:forEach>
		</form>
	</ul>
</div>
<div style="width:100%; float:left; cleat:both; display: block; margin-top: 15px;">
<form>
	<div style="float: left;">
		<input type="submit" id="btSelect" value="Select"  class="button_css"  onclick="return CloseMySelf(this);" > <input
			type="submit" id="btEdit" value="Edit"  class="button_css" > <a href="" onclick="closeWindow();"><input  class="button_css" type="submit"
			id="btClose" value="Close"></a>
	</div>
	
	<div class="phantrang">Page <input type="text" style="width: 30px"> Of 1</div>
</form>
</div>